package android.serialport.sample;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private final SerialPortCtrl mSerialPortCtrl = new SerialPortCtrl();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mSerialPortCtrl.open("/dev/ttyHSL2",115200);

        findViewById(R.id.write).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                byte[] data = new byte[]{0x24,0,0,0x1b,0x0a};
                mSerialPortCtrl.write(data,0,data.length);
            }
        });

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mSerialPortCtrl.close();
    }
}